import { TextareaItem as AntInput } from 'antd-mobile-v2';
import * as React from 'react';
import { Props, State } from '../type';

export class TextArea extends React.Component<Props, State> {
  public static defaultProps = new Props();
  public state = new State();

  public render() {
    const { getFieldProps = () => {
      //
    } } = this.props.form || {};
    const {
      rows,
      form,
      name,
      code,
      required,
      error,
      onErrorClick,
      ...otherProps
    } = this.props;
    return (
      <AntInput
        title={name}
        rows={rows}
        // autoSize={{ minRows: rows || 5, maxRows: rows || 5 }}
        // {...filterBuildInValues(otherProps)}
        {...otherProps}
        {...getFieldProps(this.props.code, {
          rules: [{ required: this.props.required, message: `请输入${name}` }]
        })}
        autoHeight={rows ? false : true}
      />
    );
  }
}
